#ifndef DIRMODEL_H
#define DIRMODEL_H

#include <QAbstractTableModel>
#include <QFileInfoList>
#include <QFileIconProvider>
#include <QMap>

class DirModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    explicit DirModel(QObject *parent = nullptr);

    // Header:
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    // Basic functionality:
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    //设置目标文件
    void SetRootDir(QString dir);
    QFileInfoList getSelectFiles();//获取选择文件
private:
    QString dirPath; // 设置的路径
    QMap<int,Qt::CheckState> check_state_map;//用来保存选中状态
    //QFileIconProvider *provider= new QFileIconProvider();
    QFileIconProvider provider;
    QFileInfoList filelist;
    void ReadFileInfo(QDir dir);

};

#endif // DIRMODEL_H
